import { IGetUsersListParams, IUserItem } from '@/types/user'
import request from '@/utils/request'
import { AxiosPromise } from 'axios'
/**
 * 获取用户信息
 * @returns
 */
function getUserInfoApi(): AxiosPromise {
  return request({
    url: '/users/getUserInfo',
    method: 'get'
  })
}

/**
 * 获取用户列表
 */
function getUsersList(params: IGetUsersListParams): AxiosPromise {
  return request({
    url: '/users/list',
    method: 'get',
    params
  })
}
/**
 * 获取全部用户
 * @returns
 */
function getAllUserList() {
  return request({
    url: '/users/all/list',
    method: 'get'
  })
}

/**
 * 创建用户
 * @param data
 * @returns
 */
function createUser(data: IUserItem): AxiosPromise {
  return request({
    url: '/users/create',
    method: 'post',
    data
  })
}

/**
 * 编辑用户
 * @param params
 * @returns
 */
function editUser(data: IUserItem): AxiosPromise {
  return request({
    url: '/users/edit',
    method: 'post',
    data
  })
}

/**
 * 删除用户
 * @param params
 * @returns
 */
function deleteUser(userIds: number[]): AxiosPromise {
  return request({
    url: '/users/delete',
    method: 'post',
    data: { userIds }
  })
}

export { getUserInfoApi, getUsersList, getAllUserList, createUser, editUser, deleteUser }
